define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'rider/index' + location.search,
                    add_url: 'rider/add',
                    edit_url: 'rider/edit',
                    del_url: 'rider/del',
                    multi_url: 'rider/multi',
                    import_url: 'rider/import',
                    table: 'rider',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'nickname', title: __('Nickname'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        // {field: 'password', title: __('Password'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'switch', title: __('Switch'), table: table, formatter: Table.api.formatter.toggle},
                        {field: 'tips', title: __('Tips'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'authen', title: __('Authen'), searchList: {"2":__('Authen 2'),"3":__('Authen 3'),"4":__('Authen 4')}, formatter: Table.api.formatter.normal},
                        // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'createtime', title: __('Createtime'), operate: 'RANGE',addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'province_name', title: __('Province_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'city_name', title: __('City_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'district_name', title: __('District_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'province_id', title: __('Province_id')},
                        // {field: 'city_id', title: __('City_id')},
                        // {field: 'district_id', title: __('District_id')},
                        // {field: 'contact_name', title: __('Contact_name'), operate: 'LIKE'},
                        // {field: 'contact_tel', title: __('Contact_tel'), operate: 'LIKE'},
                        // {field: 'legalLicenceFrontUrl', title: __('LegalLicenceFrontUrl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        // {field: 'legalLicenceBackUrl', title: __('LegalLicenceBackUrl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        // {field: 'bankCode', title: __('BankCode'), operate: 'LIKE'},
                        // {field: 'bankCardNo', title: __('BankCardNo'), operate: 'LIKE'},
                        // {field: 'applicationStatus', title: __('ApplicationStatus'), operate: 'LIKE', formatter: Table.api.formatter.status},
                        // {field: 'merchantNo', title: __('MerchantNo'), operate: 'LIKE'},
                        // {field: 'requestNo', title: __('RequestNo'), operate: 'LIKE'},
                        // {field: 'progressDescription', title: __('ProgressDescription'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'intentionAuthUrl', title: __('IntentionAuthUrl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        // {field: 'intentionAuthUrl_code', title: __('IntentionAuthUrl_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'agreementSignUrl', title: __('AgreementSignUrl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        // {field: 'agreementSignUrl_code', title: __('AgreementSignUrl_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'auditOpinion', title: __('AuditOpinion'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
